package com.zyit.web;

import com.zyit.DataObject.T_user;
import com.zyit.dao.UserDao;
import com.zyit.util.SendEmail;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/emailLonginCC")
public class EmailLonginI extends HttpServlet {
    private UserDao userDao = new UserDao();
    private SendEmail sendEmail = new SendEmail();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("方法");
        String email = req.getParameter("email");
        System.out.println(email);
        T_user tUser = userDao.emailByUser(email);
        System.out.println(tUser);
        if(tUser != null){
            String s = sendEmail.SendEmailGo(email);
            System.out.println(s);
            resp.getWriter().write("{\"status\": 1, \"data\": \"" + s + "\",\"account\": \"" + tUser.getAccount() + "\",\"password\": \"" + tUser.getPassword() + "\"}");
        }
    }
}
